package annotation;

import com.mysql.jdbc.LoadBalancedAutoCommitInterceptor;
import http.get.BaseRequest;
import org.omg.PortableServer.POA;
import spark.Request;
import spark.Response;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

/**
 * Created by LeoLu on 2017/3/16.
 */
public class HttpService{
    private String data;
    private boolean isGet = false;

    public void bind(Object t){
         Path path =  t.getClass().getAnnotation(Path.class);
        data = path.value();
        try {
          Method method =  t.getClass().getMethod("callAnyRespone",Request.class,Response.class);
          Post post = method.getAnnotation(Post.class);
          Get get = method.getAnnotation(Get.class);
          isGet = (get != null) ? true : false;
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public String getHttpPath(){
        return data;
    }

    public boolean getStatus(){
        return isGet;
    }

}
